<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prueba iva</title>
</head>

<body>
<table border="1" align="center">
<? 
include 'conexion.php';
    extract($_POST);
    extract($_GET);
/*$base= "ucg - copia";
	$conexion = mysql_connect("localhost","root","");
		mysql_select_db($base,$conexion);
      
    -$sql="Select * from cuenta_gen group by detalle";
	$resultado = mysql_query($sql, $conexion);
	while ($cuenta = mysql_fetch_array($resultado)) { */
		  
 $compr=mysql_query("SELECT compra1.cod_c, compra1.cod_ser_com, compra1.fecha, compra1.anulado, compra1.causado, id_compra.iva, id_compra.id_compra, sum((id_compra.cantidad*id_compra.pre_unit)*(id_compra.iva/100))  FROM compra1, id_compra where compra1.cod_c=id_compra.cod_c and id_compra.excento!=1 group by id_compra.id_compra",$conexion);
	while ($compra= mysql_fetch_row($compr)) { 
	$micadena="";
	
$sqlcad="Select descripcion from id_compra where cod_c='$compra[0]' and cuenta='$cuenta'";
		 $resulcad=mysql_query($sqlcad,$conexion);
	 	 while ($cad= mysql_fetch_array($resulcad)){ 	
	$micadena = $micadena . "$cad[0]"."," ; }
	
	
	$compromiso=$compra[7];
	$compromiso=round($compromiso,2);
	$compromiso1= number_format($compromiso,2,",",".");
	


$cuenta='4.03.18.01.00'; 
$cod=$compra[6];

  /*$base= "ucg - copia";
	$conexion=mysql_connect("localhost","root","");
	mysql_select_db($base,$conexion);*/
mysql_query("UPDATE id_compra SET cuenta_iva='$cuenta', valor_iva='$compromiso'  WHERE id_compra='".$cod."'",$conexion);                  ?>

  <tr>
  <td align="center"><? echo $cod; ?></td>     
    <td align="center"><? echo $cuenta; ?></td>
    <td align="center"><? echo $compromiso1; ?></td>
      </tr>
  
  <? } //}

?>
</table>
</body>
</html>
